package com.yc.springmvc.bean;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;
import java.util.Date;
import java.util.List;

@Data
public class User {
    @NotNull(message = "账号不能为null") // 判断空对象
    @NotEmpty(message = "账号不能为空字符串") // 判断空字符串
    @Length(min = 2, max = 20, message = "账号必须是2~20个字符")
    String name;
    @NotEmpty
    @Pattern(regexp = "[\\u4e00-\\u9fa5]{2,5}",
            message = "绰号必须是2~5个汉字")
    String alias;
    @Range(min = 18, max = 80, message = "年龄必须是18~80岁")
    int age;
    @NotBlank
    String edu;
    @Length(min = 6, max = 16, message = "账号必须是6~16个字符")
    String pwd;
    @Email
    String email;
    @Pattern(regexp = "\\d{6,11}",
            message = "电话号码必须是6~11个数字")
    String phone;
    @Size(min = 1, message = "爱好至少是一个!")
    List<String> likes;
    User father;
    List<User> friends;

    @NotNull
    @Past
    Date birthday;
}
